import 'dart:async';
import 'package:flutter/services.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'flutter_huawei_account_method_channel.dart';

abstract class FlutterHuaweiAccountPlatform extends PlatformInterface {
  /// Constructs a FlutterHuaweiAccountPlatform.
  FlutterHuaweiAccountPlatform() : super(token: _token);

  static final Object _token = Object();

  static FlutterHuaweiAccountPlatform _instance = MethodChannelFlutterHuaweiAccount();

  /// The default instance of [FlutterHuaweiAccountPlatform] to use.
  ///
  /// Defaults to [MethodChannelFlutterHuaweiAccount].
  static FlutterHuaweiAccountPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [FlutterHuaweiAccountPlatform] when
  /// they register themselves.
  static set instance(FlutterHuaweiAccountPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future<String?> code(){
     throw UnimplementedError('code() has not been implemented.');
  }
  
  /// 创建登录按钮工厂
  /// 这个方法用于在平台端创建原生的登录按钮视图工厂
  PlatformViewFactory? createLoginButtonFactory() {
    throw UnimplementedError('createLoginButtonFactory() has not been implemented.');
  }
}

/// 平台视图工厂接口
abstract class PlatformViewFactory {
  /// 创建平台视图控制器
  PlatformViewController create({int viewId, Map<String, dynamic> creationParams});
}